<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h1>location对象</h1>
    <input type="text" placeholder="请输入内容">
    <hr>
    <button id="reload">刷新网页-location.reload()</button>
    <button id="jump">跳转网页-location.replace()</button>
    <button id="jump2">跳转网页-location.href</button>

    <script>
        console.log(location);
        var reload = document.querySelector('#reload')
        var jump = document.querySelector('#jump')
        var jump2 = document.querySelector('#jump2')

        reload.onclick = function () {
            // 刷新网页
            location.reload()
        }
        jump.onclick = function () {
            // 以替换方式实现页面跳转: 会替换上一个网页历史记录
            location.replace('http://baidu.com')
        }
        jump2.onclick = function () {
            // 实现页面跳转: 在浏览器的访问历史记录中新增一条访问记录
            location.href='08-检测元素是否进入浏览器可视区域.html'
        }
    </script>
</body>

</html>